package com.yanghui.dtracing.core.plugin;

import com.yanghui.dtracing.core.match.ClassMatch;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.dynamic.DynamicType;

/**
 * 增强定义
 */
public interface IClassEnhancePluginDefine {

    String FIELD_ENHANCED = "_filed$enhanced";

    /**
     * 指定需要增强的类
     * @return
     */
    ClassMatch enhanceClass();

    /**
     * 构造方法切入点
     * @return
     */
    IConstructorMethodInterceptPoint[] buildConstructorMethodInterceptPoints();

    /**
     * 实例方法切入点
     * @return
     */
    IInstanceMethodInterceptPoint[] buildInstanceMethodInterceptPoints();

    /**
     * 静态方法切入点
     * @return
     */
    IStaticMethodInterceptPoint[] buildStaticMethodInterceptPoints();

    /**
     * 判断当前类路径是否存在指定类
     * @return
     */
    String[] witnessClasses();


    /**
     * 增强
     * @param builder
     * @param typeDescription
     * @param classLoader
     * @return
     */
    DynamicType.Builder<?> define(DynamicType.Builder<?> builder, TypeDescription typeDescription, ClassLoader classLoader);

}
